//
//  HomeClassAPI.swift
//  DKE-Album
//
//  Created by 杨东宝 on 2020/6/15.
//  Copyright © 2020 杨东宝. All rights reserved.
//

import Foundation

// 请求分类
public enum HomeClassAPI {
    
    case wordSearchKeyword(_ dict:[String:Any]) //搜索单词
    case getWordDetail(_ dict:[String:Any]) //单词详情
    case wordClockIn(_ dict:[String:Any]) //日历打卡
    case indexGetBookProcess //首页数据获取
    case indexGetCalendarAll //获取打卡日历
}
// 请求配置
extension HomeClassAPI: TargetType {
    
    // 各个请求的具体路径
    public var path: String {
        switch self {
        case .wordSearchKeyword:return "/word/searchKeyword"
        case .getWordDetail:return "/word/getWordDetail"
        case .wordClockIn:return "/word/clockIn"
        case .indexGetBookProcess:return "/index/getBookProgress"
        case .indexGetCalendarAll:return "/index/getCalendarAll"
        }
    }
    // 请求类型
    public var method: Moya.Method {
        switch self {
        case .wordSearchKeyword:
            return .post
        case .getWordDetail:
            return .get
        case .wordClockIn:
            return .post
        case .indexGetBookProcess:
            return .get
        case .indexGetCalendarAll:
            return .get
        }
    }
    
    // 请求任务事件（这里附带上参数）
    public var task: Task {
        
        switch self {
        case .wordSearchKeyword(dict:let dict):
            return .requestParameters(parameters: dict, encoding: URLEncoding.default)
        case .getWordDetail(dict:let dict):
            return .requestParameters(parameters: dict, encoding: URLEncoding.default)
        case .wordClockIn(dict:let dict):
            return .requestParameters(parameters: dict, encoding: URLEncoding.default)
        case .indexGetBookProcess:
            return .requestPlain
        case .indexGetCalendarAll:
            return .requestPlain
        }
    }
    // 是否执行Alamofire验证
    public var validate: Bool {
        return false
    }
    
}

